package com.example.juheweixin;

import android.content.Context;
import android.util.Log;

import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;

public class HttpUtilsHelp extends HttpUtils{
	private static final String WEIXIN_URL = "http://v.juhe.cn/weixin/query?key=52b807e594eeb1c903d22315bd0e1636";
	
	public HttpUtilsHelp(Context context) {
		configCurrentHttpCacheExpiry(1000);
		
	}
	
	private void postData(String url, RequestParams params, RequestCallBack<String> callBack) {
		send(HttpRequest.HttpMethod.POST,
				url,
			    params,callBack);
	}
	
	private void httpGet(String url, RequestParams params, 
			RequestCallBack<String> callBack) {
		Log.i("guanting", "httpGet url = " + url);
		send(HttpRequest.HttpMethod.GET,
				url,
				params,callBack);
	}
	
	public void getWeixinByGet(int pno, int ps, RequestCallBack<String> callBack) {
		httpGet(WEIXIN_URL + "&pno=" + pno + "&ps=" + ps, null, callBack);
	}
	
	public void getWeixinByPost(int pno, int ps, RequestCallBack<String> callBack) {
		RequestParams params = new RequestParams();
		params.addBodyParameter("pno", pno + "");
		params.addBodyParameter("ps", ps + "");
		postData(WEIXIN_URL, params, callBack);
	}
	
	
}
